// 导入vue
import Vue from 'vue'
// 导入根组件
import App from './App.vue'
// 导入路由
import router from './router/index'
//导入element
import './plugins/element.js'
//导入treetable
import TreeTable from 'vue-table-with-tree-grid'
// 导入字体图标样式表
import './assets/fonts/iconfont.css'
// 导入全局css
import '../src/assets/css/global.css'
//导入富文本
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
Vue.use(VueQuillEditor)


Vue.config.productionTip = false
// 导入axios
import axios from 'axios'
//配置axios根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
//设置请求拦截器
axios.interceptors.request.use(config => {
  // 设置请求头
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config;
})

// 将axios挂载到Vue构造函数的原型上 全局使用
Vue.prototype.axios = axios
//全局祖册树形表格组件
Vue.component('tree-table', TreeTable)

//定义时间过滤器
Vue.filter('dateFormat', (time) => {
  const data = new Date(time);
  const YY = data.getFullYear();
  const MM = (data.getMonth() + 1 + "").padStart(2, "0");
  const DD = (data.getDate() + "").padStart(2, "0");
  const hh = (data.getHours() + "").padStart(2, "0");
  const mm = (data.getMinutes() + "").padStart(2, "0");
  const ss = (data.getSeconds() + "").padStart(2, "0");
  return `${YY}-${MM}-${DD} ${hh}:${mm}:${ss}`;
})


new Vue({
  //使用路由
  router,
  render: h => h(App)
  ,
  mounted() {
    layui.use('layer', function () {
      var layer = layui.layer
    })
  },
  //在实例后面添加$mount('#app')就类似于 在实例里添加  el:'#app'
}).$mount('#app')
